<template>
	<div class="base-nav">
		<ul class="nav-ul">
			<li class="nav-home" @click="linkTo('home')">
				<a href="#">
					<i class="graph graph-home"></i>
				</a>
			</li>
			
			<li v-for="item in navItems" :key="item.id" @click="showTitle">
				<a>
					<i :class="`graph `+item.icon"></i>
					<span>{{item.name}}</span>
				</a>
			</li>
		</ul>
	</div>

</template>

<script>
export default {
  name: "TopNav",
  props: {
    navItems: Array
  },
  methods: {
    linkTo: function(path) {
      this.$store.commit("changeTitle", path);
    },
    showTitle: function() {
      alert(this.$store.state.title);
    }
  }
};
</script>

<style lang="less">
.base-nav {
  .nav-ul {
    li {
      float: left;
      position: relative;
      transition: background-color 0.2s linear, color 0.2s linear;
      a {
        background: 0;
        width: 88px;
        text-align: center;
        display: block;
        line-height: 50px;
        align-items: center;
        padding: 0 12px;
        height: 50px;
        font-size: 14px;
        color: #fff;
        text-decoration: none;
        overflow: hidden;
        text-overflow: ellipsis;
        transition: background-color 1s linear, color 0.2s linear;
        .graph-home {
          background-position: 0 0;
          height: 16px;
          width: 16px;
          margin-top: -3px;
        }
        .graph-task {
          background-position: -32px 0;
        }
        .graph-email {
          background-position: -193px -32px;
        }
      }
      span {
        margin-left: 6px;
        white-space: nowrap;
      }
      .graph {
        height: 16px;
        width: 16px;
        margin-top: -3px;
      }
    }
    li:hover,
    .active {
      cursor: pointer;
      background-color: rgba(0, 0, 0, 0.1);
    }
    .nav-home {
      a {
        width: auto;
      }
    }
  }
  .graph {
    height: 16px;
    width: 16px;
  }
}
</style>
